package com.sumainfor.wx.tenant.controller;

import com.sumainfor.common.util.ContextUtils;
import com.sumainfor.common.util.FieldCheckUtil;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.wx.tenant.feign.OperationsFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 功能描述:
 * 租客投诉相关
 *
 * @Auther: zhlu
 * @Date: 2019/5/11 11:01
 * @Description:
 */
@RestController
@RequestMapping("/complaint")
public class ComplaintController {

    @Autowired
    OperationsFeignClient OperationsFeignClient;

    /**
     * 功能描述:
     * 租客端发起投诉
     *
     * @Author zhlu
     * @Description //TODO
     * @Date 2019/5/11 11:03
     */
    @RequestMapping(value = "/AddTenantComplaint", method = RequestMethod.POST)
    public JsonResult AddTenantComplaint(@RequestBody Map<String, Object> params) {
        return OperationsFeignClient.AddTenantComplaint(params);
    }


    /**
     * 提交线上与线下建议
     *
     * @param params
     * @return
     */
    @PostMapping("/submitSurvey")
    public JsonResult submitSurvey(@RequestBody Map<String, Object> params) {
        if (!FieldCheckUtil.isMapFieldNotNull(params, "Answer", "TenType", "Picture")) {
            return JsonResult.errorForEmpty();
        }
        params.put("TenId", ContextUtils.getWxInfo().getTenId());
        return OperationsFeignClient.submitSurvey(params);
    }
}
